﻿using System;
using SassAndCoffee;

namespace Telerik.Web.Mvc.UI {
    public static class CoffeeRegistrarBuilder {
        private static CoffeeScriptFileCompiler _compiler = new CoffeeScriptFileCompiler();

        public static ScriptRegistrarBuilder Coffee(this ScriptRegistrarBuilder scriptRegistrar, Action<CoffeeCollectionBuilder> configureAction) {
            var registrar = (ScriptRegistrar)scriptRegistrar;

            CoffeeCollectionBuilder builder = new CoffeeCollectionBuilder(WebAssetType.JavaScript, registrar.Scripts, _compiler);

            configureAction(builder);

            return scriptRegistrar;
        }

        public static ScriptRegistrarBuilder DefaultCoffeeGroup(this ScriptRegistrarBuilder scriptRegistrar, Action<SassAndCoffeeGroupBuilder> configureAction) {
            var registrar = (ScriptRegistrar)scriptRegistrar;

            SassAndCoffeeGroupBuilder builder = new SassAndCoffeeGroupBuilder(registrar.DefaultGroup, _compiler);

            configureAction(builder);

            return scriptRegistrar;
        }
    }
}